#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct bz
{
    char name[23];
    int score;
};
int main()
{
    int n;
    char a[30];
    struct bz s[5]={"Huang",0,"Ouyang",0,"Duan",0,"Hong",0,"Wang",0};
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s",a);
        if(a[0]=='H'&&a[1]=='u')
        {
            s[0].score++;
        }
        else if(a[0]=='O')
        {
            s[1].score++;
        }
        else if(a[0]=='D')
        {
            s[2].score++;
        }
        else if(a[0]=='H'&&a[1]=='o')
        {
            s[3].score++;
        }
        else if(a[0]=='W')
        {
            s[4].score++;
        }
    }
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<4-i;j++)
        {
            if((s[j+1].score)>(s[j].score))
            {
                struct bz t;
                t=s[j+1];
                s[j+1]=s[j];
                s[j]=t;
            }
        }
    }
    for(int i=0;i<5;i++)
    {
        printf("%s %d\n",s[i].name,s[i].score);
    }
    return 0;
}
